home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / pxewin.zip / DBDISPLY.HPP < prev    next >
C/C++ Source or Header  |  1992-02-14  |  7KB  |  237 lines

  1. // PXEWIN - (C) Copyright 1992 by Beam Engineering, INC.
  2.  
  3. // DBDISPLY.HPP //
  4.  
  5. // Contents ----------------------------------------------------------------
  6. //
  7. //    This module is used to interface the PDOX Engine with the OWL.  List
  8. //    boxes are used to display the contents of each field in the database.
  9. //    An array of list box parameters keeps track of each list box.
  10. //
  11. //    This header contains the following items:
  12. //
  13. //    1.  Messages used for dispatching between OWL classes.
  14. //
  15. //    2.  LB_PARM.  This structure is for parametric defining each list
  16. //        box.
  17. //    3.  Class DBDISPLAY.  Displays the database in page format with 20
  18. //    records per page.
  19. //
  20. //    Most of the persistant object interface has been left undefined
  21. //    up to this point.  The reason for this is due to the changability
  22. //    of the database.  If your operating on a Network and sharing a table
  23. //    then there is a lot that can happen to a database between sessions.
  24. //    About the only thing your going to need to save is the record
  25. //    pointer and field pointer and even they might not be valid in your
  26. //    next session.  DBDISPLAY saves off the record pointer to the stream
  27. //    and also checks for it's validity at the beginning of your next
  28. //    session.
  29. //
  30. // End ---------------------------------------------------------------------
  31.  
  32. // External Reference Name for this Header ---------------------------------
  33.  
  34. #ifndef DBDISPLY_HPP
  35.     #define DBDISPLY_HPP
  36.  
  37. // End ---------------------------------------------------------------------
  38.  
  39. // Interface Dependendies --------------------------------------------------
  40.  
  41. #ifndef __STRING_H
  42.     #include <string.h>
  43. #endif // __STRING_H //
  44.  
  45. #ifndef __STDIO_H
  46.     #include <stdio.h>
  47. #endif // __STDIO_H //
  48.  
  49. #ifndef __OWL_H
  50.     #include <owl.h>
  51. #endif // __OWL_H //
  52.  
  53. #ifndef __FILEDIAL_H
  54.     #include <filedial.h>
  55. #endif // __FILEDIAL_H //
  56.  
  57. #ifndef __MDI_H
  58.     #include <mdi.h>
  59. #endif // __MDI_H //
  60.  
  61. #ifndef __LISTBOX_H
  62.     #include <listbox.h>
  63. #endif // __LISTBOX_H //
  64.  
  65. #ifndef __STATIC_H
  66.     #include <static.h>
  67. #endif // __STATIC_H //
  68.  
  69. #ifndef __EDIT_H
  70.     #include <edit.h>
  71. #endif // __EDIT_H //
  72.  
  73. #ifndef PXDIS_CPP
  74.     #include "pxdis.cpp"
  75. #endif // PXDIS_CPP //
  76.  
  77. // End ---------------------------------------------------------------------
  78.  
  79. #define PAGE_SIZE 20                /* The number of records in
  80.                            a page */
  81.  
  82. #define WM_CHKCHILD 0x400            /* To send a message to the
  83.                            BrowserFrame when a
  84.                            child is destroyed */
  85.  
  86. #define WM_SETWTCUR 0x401            /* Cursor wait message */
  87. #define WM_SETNMCUR 0x402            /* Cursor normal message */
  88. #define WM_PXERROR 0x403            /* PX Engine Error */
  89. #define CM_OPENED 0x1                /* Open desktop */
  90. #define CM_SAVEDT 0x2                /* Save desktop */
  91.  
  92. // structure LB_PARM //
  93.  
  94. // You'll need to references the following in advance of their definitions.
  95.  
  96. _CLASSDEF(PXListBox)
  97. class PXListBox;                /* Redefined TListBox for
  98.                            Engine compatibility. */
  99. _CLASSDEF(Browser)
  100. class Browser;                    /* Define the Browser class
  101.                            which is the parent
  102.                            window. */
  103.  
  104. typedef struct LB_PARM{
  105.     PPXField my_field;            /* Points to the field
  106.                            cooresponding to this
  107.                            list box */
  108.     long x;                    /* X coordinates of origin
  109.                            point of list box */
  110.     long w;                    /* Width of list box */
  111.     PPXListBox my_box;            /* Points to the list box
  112.                            object */
  113.     PTStatic my_header;            /* Points to field header
  114.                            static text block object
  115.                         */
  116. }LB_PARM;
  117.  
  118. typedef LB_PARM _FAR *PLB_PARM;            /* Make DLL compatible
  119.                            pointers */
  120. typedef LB_PARM _FAR **PPLB_PARM;
  121.  
  122. // Description -------------------------------------------------------------
  123. //
  124. //    This structure is used to define the parameters necessary to
  125. //    construct and use a list box for each field in the database.
  126. //
  127. // End ---------------------------------------------------------------------
  128.  
  129. // class DBDISPLAY //
  130.  
  131. _CLASSDEF(DBDISPLAY)
  132. class DBDISPLAY:public PXDIS
  133. {
  134. private:
  135.     virtual const Pchar streamableName()
  136.     const                    /* Defines the streamable
  137.                            name for this class. */
  138.     {
  139.         return "DBDISPLAY";
  140.     }
  141. protected:
  142.     long sum;                /* sum is the total number of
  143.                            characters it takes to
  144.                            display all the fields.
  145.                            This will be used to set
  146.                            the scroll bar range. */
  147.     PTWindowsObject AP;            /* Copy of parent object */
  148.     int UpdateFlag;                /* Update display if set */
  149.     int char_width;                /* This is the maximum
  150.                            character width of the
  151.                            current font */
  152.     virtual Pvoid read(Ripstream);        /* Read persistant object */
  153.     virtual void write(Ropstream);        /* Write persistant object */
  154.     DBDISPLAY(StreamableInit):        /* Persistant object
  155.                            constructor */
  156.         PXDIS(streamableInit)
  157.     {
  158.  
  159.     }
  160. public:
  161.     PPLB_PARM my_parm;                      /* Define an array of
  162.                            pointers for the fields
  163.                            parameter set */
  164.     RECORDNUMBER top_rec;            /* Top record number */
  165.     int item;                /* List box item number */
  166.     int field;                /* Number of currently
  167.                            selected field */
  168.  
  169.     DBDISPLAY();
  170.     static PTStreamable build();        /* Build persistant object */
  171.     int RetSum()                /* Returns the total number
  172.                            of characters in all
  173.                            fields */
  174.     {
  175.         return sum;
  176.     }
  177.     virtual ~DBDISPLAY();
  178.     int SetUp(PBrowser AParent);        /* Set up database display */
  179.     void SelRecord(int item);        /* Selects the record at a
  180.                            certain list box item
  181.                            number */
  182.     void FillBoxes(RECORDNUMBER rec);    /* Fills list boxes with
  183.                            data */
  184.     void ScrollUp();            /* Scrolls the page up by one
  185.                            record */
  186.     void ScrollDwn();            /* Scrolls the page down by
  187.                            one record */
  188.     void IncRec();                /* Increments by one record
  189.                         */
  190.     void DecRec();                /* Decrements by one record
  191.                         */
  192.     RECORDNUMBER RetCurRec()        /* Return current record */
  193.     {
  194.         return top_rec + item;
  195.     }
  196.     int RetFlag()                /* Returns status of update
  197.                            flag to test if display
  198.                            should be updated or not
  199.                         */
  200.     {
  201.         return UpdateFlag;
  202.     }
  203.     int RetCharWidth()            /* Returns the character
  204.                            width for the current font
  205.                         */
  206.     {
  207.         return char_width;
  208.     }
  209.     virtual void PXError(int org);        /* DBDISPLAY error handler */
  210.     int RetField()                /* Return field number */
  211.     {
  212.         return field;
  213.     }
  214. };
  215.  
  216. // Description -------------------------------------------------------------
  217. //
  218. //    This class contains all the members necessary to initialize, browse
  219. //    and edit the database.
  220. //
  221. // End ---------------------------------------------------------------------
  222.  
  223. // Define inserters and extractors for persistant objects:
  224.  
  225. inline Ripstream operator >> (Ripstream is,RDBDISPLAY cl)
  226.     {return is >> (RTStreamable)cl;}
  227.  
  228. inline Ripstream operator >> (Ripstream is,RPDBDISPLAY cl)
  229.     {return is >> (RPvoid)cl;}
  230.  
  231. inline Ropstream operator << (Ropstream os,RDBDISPLAY cl)
  232.     {return os << (RTStreamable)cl;}
  233.  
  234. inline Ropstream operator << (Ropstream os,PDBDISPLAY cl)
  235.     {return os << (PTStreamable)cl;}
  236.  
  237. #endif // DBDISPLY_HPP //